www.gusucode.com > Webmeng PHP版Web公司企业网站管理系统 v3.1.0PHP源码程序 > Webmeng PHP版Web公司企业网站管理系统 v3.1.0/WebmengWeb v3.1.0_CN/WebmengWeb v3.1.0_CN/upload/conmeng/modules/join/statics/js/roller.js

    var roller=function(){
	return{
		init:function(el,ty,sx,ex,d,st){
			e=document.getElementById(el);if(!e){return;}a=e.getElementsByTagName("a");
			for(i=0;i<a.length;i++){
				if(!a[i].id){a[i].id=el.id+i;}
				a[i].n=a[i].o=sx;a[i].en=ex; a[i].ty=ty;				
				if(a[i].ty=='v'){a[i].style.backgroundPosition = '0px '+a[i].n+'px';}
				else if(a[i].ty=='h'){a[i].style.backgroundPosition = a[i].n+'px 0px';}
				else{return;}
				a[i].onmouseover=roller.o;a[i].onmouseout=roller.o;
				a[i].st=Math.abs(Math.abs(ex-sx)/st);a[i].t=d/st;
			}
		},
		o:function(e){
			e=e||window.event;c=e.target!=null?e.target:e.srcElement;
			if(c.nodeName=='A' && e.type=="mouseover"){c.w=c.en;roller.s(c);}
			else if(c.nodeName=='A'){c.w=c.o;roller.s(c);}
		},
		s:function(e){
			if(e.ti){clearTimeout(e.ti);}
			if(Math.abs(e.n-e.w)<e.st){e.n=e.w;}
			else if(e.n<e.w){e.n=e.n+e.st;}
			else if(e.n>e.w){e.n=e.n-e.st;}			
			if(e.ty=='v'){e.style.backgroundPosition = '0px '+e.n+'px';}
			else{e.style.backgroundPosition = e.n+'px 0px';}
			if(e.n==e.w){clearTimeout(e.ti);return;}
			e.ti=setTimeout(function(){roller.s(e)}, e.t);
		}
	}
}();

QuickMenu = function(element, startPoint, endPoint) {
	var STATICMENU = element;
	var stmnScrollSpeed = 1;
	var stmnTimer;
	
	RefreshStaticMenu = function ()
	{
		var stmnStartPoint = parseInt(STATICMENU.style.top, 10);
		var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
		var stmnEndPoint = parseInt(scrollTop, 10)+endPoint;
		var stmnRefreshTimer = 1;
		
		if ( stmnStartPoint != stmnEndPoint ) {
				stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint - stmnStartPoint ) / 17 );
				STATICMENU.style.top = parseInt(STATICMENU.style.top, 10) + ( ( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount ) + "px";
				stmnRefreshTimer = stmnScrollSpeed;
		}
		stmnTimer = setTimeout ("RefreshStaticMenu();", stmnRefreshTimer);
	}
	this.InitializeStaticMenu = function ()
	{
			STATICMENU.style.top = startPoint + "px";
			RefreshStaticMenu();
	}
}